﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RedBlackTreeCodeContractHelper.cs" company="Team Awesome">
//   Awesome
// </copyright>
// <summary>
//   Defines the RedBlackTreeCodeContractHelper type.
//
//	 Commented out until work is resumed to avoid an overflow of warnings.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

////namespace System.Collections.Generic
////{
////    using Diagnostics.Contracts;

////    /// <content>
////    /// Contains the contracts
////    /// </content>
////    public partial class RedBlackTree<T> where T : IComparable
////    {
////        /// <summary>
////        /// Gets the number of black children or returns -1 if they haven't been equal from bottom up.
////        /// </summary>
////        /// <param name="node">
////        /// The node.
////        /// </param>
////        /// <returns>
////        /// Number of black children and -1 if they havent been equal from bottom up.
////        /// </returns>
////        [Pure]
////        [ContractRuntimeIgnored]
////        private static int AmountOfBlackChildren(Node node)
////        {
////            if (node == null)
////                return 0;

////            var leftBlackChildren = AmountOfBlackChildren(node.Left);
////            var rightBlackChildren = AmountOfBlackChildren(node.Right);

////            if (leftBlackChildren == -1 || rightBlackChildren == -1 || leftBlackChildren != rightBlackChildren)
////                return -1;

////            var blackChildren = leftBlackChildren + rightBlackChildren;

////            return blackChildren + (!node.IsRed ? 1 : 0);
////        }

////        /// <summary>
////        /// Checks if there is the same amount of black notes in the left and right subtree from every subtree in the tree.
////        /// </summary>
////        /// <returns>
////        /// A boolean stating if there is the same amount of black notes in the left and right subtree from every subtree in the tree.
////        /// </returns>
////        [Pure]
////        [ContractRuntimeIgnored]
////        private bool EqualAmountOfBlackNodes()
////        {
////            return -1 != AmountOfBlackChildren(_root);
////        }

////        /// <summary>
////        /// Checks if the tree is without 4 nodes or right leaning 3 nodes. That is, if any node has a red child to the right.
////        /// </summary>
////        /// <param name="failureCondition">
////        /// The failure Condition to be posted if the method return false.
////        /// </param>
////        /// <returns>
////        /// Returns false if a 4 node or right leaning 3 node is found. Else true.
////        /// </returns>
////        [Pure]
////        [ContractRuntimeIgnored]
////        private bool CheckTreeColourStructure(out string failureCondition)
////        {
////            return CheckTreeColourStructure(_root, out failureCondition);
////        }

////        /// <summary>
////        /// Makes sure the tree does not contain any right leaning 3 nodes. That is, if any node has a red child to the right.
////        /// or
////        /// Makes sure the tree does not contain any 4 nodes. That is, if a node has 2 red children.
////        /// and
////        /// Makes sure the tree does not contain two concussive red nodes. A red node must not have a red child.
////        /// </summary>
////        /// <param name="h">
////        /// The node which to check if its subtrees contains 4 nodes or right leaning 3 nodes.
////        /// </param>
////        /// <param name="failureCondition">
////        /// The failure Condition.
////        /// </param>
////        /// <returns>
////        /// Returns false if a 4 node or right leaning 3 node is found. Else true.
////        /// </returns>
////        [Pure]
////        [ContractRuntimeIgnored]
////        private static bool CheckTreeColourStructure(Node h, out string failureCondition)
////        {
////            if (h == null)
////            {
////                failureCondition = TreeColourStructureCondition.NoFailure;
////                return true;
////            }

////            // Is right leaning 3 node or 4 node
////            if (h.Right != null && h.Right.IsRed)
////            {
////                failureCondition = TreeColourStructureCondition.RightLeaningOrFourNode;
////                return false;
////            }

////            // There are two red nodes in a row
////            if (h.IsRed && h.Left != null && h.Left.IsRed)
////            {
////                failureCondition = TreeColourStructureCondition.TwoRedNodesInARow;
////                return false;
////            }

////            return CheckTreeColourStructure(h.Left, out failureCondition) && CheckTreeColourStructure(h.Right, out failureCondition);
////        }

////        /// <summary>
////        /// Failure condition for invariance check methods.
////        /// </summary>
////        private static class TreeColourStructureCondition
////        {
////            /// <summary>
////            /// Succeeded state.
////            /// </summary>
////            public const string NoFailure = "Succeeded.";

////            /// <summary>
////            /// A node had a right red child.
////            /// </summary>
////            public const string RightLeaningOrFourNode = "A node had a right red child";

////            /// <summary>
////            /// A node and its child are both red.
////            /// </summary>
////            public const string TwoRedNodesInARow = "A node and its child are both red.";
////        }
////    }
////}
